%% Author: Dmitriid
%% Created: 19.09.2006
%% Description: TODO: Add desciption to test_soap
-module(test_soap).

%%
%% Include files
%%

-include("./../include/erlsoap.hrl").
-include_lib("stdlib/include/qlc.hrl").


%%
%% Defines
%%

-define(JANUS_XSD_URI,'http://rsdn.ru/ws/JanusAT.asmx?WSDL').
-define(JANUS_URI,'http://sms-service.com/schema/sms/v1_0').
-define(JANUS_WSDL_URI,'http://rsdn.ru/ws/JanusAT.asmx?WSDL').
-define(JANUS_WSDL_SERVICE_URI,'http://rsdn.ru/ws/JanusAT.asmx').


%%
%% Exported Functions
%%
-export([run/0]).
 
%%
%% API Functions
%%

run() ->    
    application:start(mnesia),
    erlsoap:create_tables(),
    soap_registry_server:start_link(),
	soap_registry_server:add_operation({?JANUS_WSDL_URI,"GetForumList"},                              
                              {?JANUS_WSDL_SERVICE_URI, "GetForumList"},
                              {?JANUS_WSDL_SERVICE_URI, "GetForumListResponse"},
                              []),
	soap_registry_server:add_message({?JANUS_WSDL_SERVICE_URI, "GetForumList"},
			     		[{"forumRequest",{?JANUS_XSD_URI, "ForumRequest"}}]),
	soap_registry_server:add_type({?JANUS_XSD_URI,"ForumRequest"},
                     {complex_type,
                      {sequence,
                       [{"userName",{?XMLSchemaURI,"string"},0,1},
                       {"password",{?XMLSchemaURI,"string"},0,1}]}}),

	soap_registry_server:add_message({?JANUS_WSDL_SERVICE_URI, "GetForumListResponse"},
			     		[{"GetForumListResult",{?JANUS_XSD_URI,"ForumResponse"}}]),

	soap_registry_server:add_type({?JANUS_XSD_URI,"ForumResponse"},
                     {complex_type,
                      {sequence,
                       [{"forumList",{?JANUS_XSD_URI,"ArrayOfJanusForumInfo"},0,1},
                        {"groupList",{?JANUS_XSD_URI,"ArrayOfJanusForumGroupInfo"},0,1}]}}),
	soap_registry_server:add_type({?JANUS_XSD_URI,"ArrayOfJanusForumInfo"},
                     {complex_type,
                      {sequence,
                       [{"JanusForumInfo",{?JANUS_XSD_URI,"JanusForumInfo"},0,unbounded}]}}),
	soap_registry_server:add_type({?JANUS_XSD_URI,"JanusForumInfo"},
                     {complex_type,
                      {sequence,
                       [{"forumId",{?XMLSchemaURI,"int"},1,1},
                        {"forumGroupId",{?XMLSchemaURI,"int"},1,1},
                        {"shortForumName",{?XMLSchemaURI,"string"},0,1},
                        {"forumName",{?XMLSchemaURI,"string"},0,1},
                        {"rated",{?XMLSchemaURI,"int"},1,1},
                        {"inTop",{?XMLSchemaURI,"int"},1,1},
                        {"rateLimit",{?XMLSchemaURI,"int"},1,1}]}}),
	soap_registry_server:add_type({?JANUS_XSD_URI,"ArrayOfJanusForumGroupInfo"},
                     {complex_type,
                      {sequence,
                       [{"JanusForumGroupInfo",{?JANUS_XSD_URI,"JanusForumGroupInfo"},0,unbounded}]}}),
	soap_registry_server:add_type({?JANUS_XSD_URI,"JanusForumInfo"},
                     {complex_type,
                      {sequence,
                       [{"forumGroupId",{?XMLSchemaURI,"int"},1,1},
                        {"forumGroupName",{?XMLSchemaURI,"string"},0,1},
                        {"sortOrder",{?XMLSchemaURI,"int"},0,1}]}}),
    %F = fun() ->
	%    Q = qlc:q([O || O <- mnesia:table(soap_operation)]),
    % 	qlc:e(Q)
   	%end,
    %I = mnesia:transaction(F),
    %io:format("Tables: ~p~n", [I]),
    soapclient:invoke(?JANUS_WSDL_SERVICE_URI,"GetForumList", 
                      {?JANUS_WSDL_URI, "GetForumList"}, 
                      [["dmitriid", 
                                         "password"]])

	
	
	.

%%
%% Local Functions
%%

